package com.jyw.business.de.domain.dto.web;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jyw.business.de.domain.DeDemandInfo;
import com.jyw.business.de.domain.DeDemandSub;
import com.jyw.common.utils.bean.BeanUtils;
import com.jyw.system.domain.vo.SimpleFileVo;
import com.jyw.system.utils.FileUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.CollectionUtils;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

@Data
@ApiModel("新增需求请求实体")
public class DemandInfoEditDto extends DemandInfoAddDto{

    @ApiModelProperty("需求主键")
    private Long id;


    @Override
    public DeDemandInfo buildDemand() {
        DeDemandInfo info = super.buildDemand();
        info.setId(getId());
        return info;
    }

    public List<DeDemandSub> buildSub() {
        return getSubInfo().stream().map(data -> {
            DeDemandSub sub = new DeDemandSub();
            BeanUtils.copyProperties(data, sub);
            sub.setDemandId(getId());
            return sub;
        }).collect(Collectors.toList());
    }
}
